package com.xkl.springdoc.controller.api;

import com.xkl.springdoc.service.ISaleListService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import com.xkl.springdoc.request.SaleListDTO;
import com.xkl.springdoc.common.R;

/**
 * 订单管理
 *
 * @version: 1.0.0-SNAPSHOT
 * @author: 码农小卡拉
 * @createTime: 2025-09-18 13:54
 **/
@Tag(name = "订单管理", description = "订单新增、查询、修改、删除等核心接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/saleList")
public class SaleListController {

    private final ISaleListService saleListService;

    /**
     * 根据id查询订单
     * @param id
     * @return
     */
    @GetMapping("/selectById")
    public R selectById(@RequestParam("id") Long id) {
        return saleListService.getSaleList(id);
    }

    /**
     * 新增订单
     * @param saleListDTO
     * @return
     */
    @PostMapping("/add")
    public R addSaleList(@RequestBody SaleListDTO saleListDTO) {
        return R.ok(saleListService.addSaleList(saleListDTO));
    }
    /**
     * 删除订单
     * @param id
     * @return
     */
    @PostMapping("/delete")
    public R deleteSaleList(@RequestParam("id") Long id) {
        return R.ok(saleListService.deleteSaleList(id));
    }
    /**
     * 更新订单
     * @param saleListDTO
     * @return
     */
    @PostMapping("/editUser")
    public R editSaleList(@RequestBody SaleListDTO saleListDTO) {
        return R.ok(saleListService.editSaleList(saleListDTO));
    }
    /**
     * 订单列表
     * @return
     */
    @PostMapping("/list")
    public R listSaleList() {
        return R.ok(saleListService.getSaleLists());
    }
}
